package cn.edu.zjicm.wordsnet_d.view;

import android.annotation.SuppressLint;
import android.content.Context;
import android.util.AttributeSet;
import android.widget.LinearLayout;
import cn.edu.zjicm.wordsnet_d.util.Utils;

public class DynamicHeightLinearLayout extends LinearLayout {

	public DynamicHeightLinearLayout(Context context) {
		super(context);
	}

	public DynamicHeightLinearLayout(Context context, AttributeSet attrs) {
		super(context, attrs);
	}

	@SuppressLint("NewApi")
	public DynamicHeightLinearLayout(Context context, AttributeSet attrs, int defStyle) {
		super(context, attrs, defStyle);
	}

	@Override
	protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
		int mode = MeasureSpec.getMode(widthMeasureSpec);
		int height = Utils.getScreenWidth(getContext());
		heightMeasureSpec = MeasureSpec.makeMeasureSpec(height / 3, mode);
		super.onMeasure(widthMeasureSpec, heightMeasureSpec);
	}

}
